﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="PhotoDetail.aspx.vb" Inherits="FishTank.PhotoDetail" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <asp:ScriptManager ID="QuestionDetailScriptManager" runat="server"></asp:ScriptManager>
        <asp:FormView ID="DetailFormView" runat="server" width="100%" CssClass="detailView">
            <EditItemTemplate>
                <h1>Edit photo</h1>

                <span class="failureNotification">
                    <asp:Literal ID="FailureText" runat="server"></asp:Literal>
                </span>
                <asp:ValidationSummary ID="PhotoInfoValidationSummary" runat="server" CssClass="failureNotification" 
                     ValidationGroup="PhotoInfoValidationGroup"/>

                <div class="itemInfo">
                <fieldset class="item">
                    <legend>Photo Information</legend>
                    <p>
                        <asp:Label ID="TitleLabel" runat="server" AssociatedControlID="TitleTextBox">Title:</asp:Label>
                        <asp:TextBox ID="TitleTextBox" runat="server" CssClass="textEntry"
                                     Text='<%# Bind("Title") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="TitleRequiredValidator" runat="server" ControlToValidate="TitleTextBox" 
                             CssClass="failureNotification" ErrorMessage="Title is required." ToolTip="Title is required." 
                             ValidationGroup="PhotoInfoValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="DescriptionLabel" runat="server" AssociatedControlID="DescriptionTextBox">Description:</asp:Label>
                        <asp:TextBox ID="DescriptionTextBox" runat="server" CssClass="textEntry" TextMode="MultiLine"
                                     Text='<%# Bind("Description") %>'></asp:TextBox>
                    </p>
                    <p>
                        <asp:Label ID="PhotoLabel" runat="server" AssociatedControlID="PhotoFileUpload">Upload a Photo:</asp:Label>
                        <asp:FileUpload ID="PhotoFileUpload" runat="server" Width="100%" />
                    </p>
                    <p>
                        <asp:Label ID="CurrentPhotoLabel" runat="server" AssociatedControlID="CurrentPhotoImage">Current Photo:</asp:Label>
                        <asp:Image ID="CurrentPhotoImage" runat="server" ImageUrl='<%# GetPhotoNormalPath(Eval("ImagePath")) %>' AlternateText="<%# Bind('Title') %>"/>
                    </p>
                </fieldset>
                <p class="submitButton">
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" 
                        ValidationGroup="PhotoInfoValidationGroup" CausesValidation="False"
                        onclick="CancelEditButton_Click"/>
                    <asp:Button ID="SaveButton" runat="server" CommandName="Save" Text="Save" 
                        ValidationGroup="PhotoInfoValidationGroup" onclick="SaveButton_Click"/>
                </p>
                </div>
            </EditItemTemplate>
            <InsertItemTemplate>
                <h1>Add your photo</h1>

                <span class="failureNotification">
                    <asp:Literal ID="FailureText" runat="server"></asp:Literal>
                </span>
                <asp:ValidationSummary ID="PhotoInfoValidationSummary" runat="server" CssClass="failureNotification" 
                     ValidationGroup="PhotoInfoValidationGroup"/>

                <div class="itemInfo">
                <fieldset class="item">
                    <legend>Photo Information</legend>
                    <p>
                        <asp:Label ID="TitleLabel" runat="server" AssociatedControlID="TitleTextBox">Title:</asp:Label>
                        <asp:TextBox ID="TitleTextBox" runat="server" CssClass="textEntry" Text=""></asp:TextBox>
                        <asp:RequiredFieldValidator ID="TitleRequiredValidator" runat="server" ControlToValidate="TitleTextBox" 
                             CssClass="failureNotification" ErrorMessage="Title is required." ToolTip="Title is required." 
                             ValidationGroup="PhotoInfoValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="DescriptionLabel" runat="server" AssociatedControlID="DescriptionTextBox">Description:</asp:Label>
                        <asp:TextBox ID="DescriptionTextBox" runat="server" CssClass="textEntry" TextMode="MultiLine"
                                     Text=""></asp:TextBox>
                    </p>
                    <p>
                        <asp:Label ID="PhotoLabel" runat="server" AssociatedControlID="PhotoFileUpload">Upload a Photo:</asp:Label>
                        <asp:FileUpload ID="PhotoFileUpload" runat="server" Width="100%" />
                    </p>
                </fieldset>
                <p class="submitButton">
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" 
                        ValidationGroup="PhotoInfoValidationGroup" CausesValidation="False"
                        PostBackUrl="~/Pages/QuestionList.aspx" />
                    <asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" 
                        ValidationGroup="PhotoInfoValidationGroup" onclick="SubmitButton_Click"/>
                </p>
                </div>
            </InsertItemTemplate>
            <ItemTemplate>
                <h1><asp:Label ID="TitleLabel" runat="server" Text="<%# Bind('Title') %>"></asp:Label></h1>

                <p class="author">
                    by
                    <a href="/Pages/MemberDetail.aspx?UserName=<%# Eval("MemberUserName") %>">
                        <asp:Label ID="MemberLabel" runat="server" Text='<%# Bind("MemberFullName") %>' />
                    </a>
                    at
                    <asp:Label ID="CreatedDateLabel" runat="server" Text='<%# Bind("CreatedDateTime", "{0:MMMM d, yyyy}") %>' />
                </p>

                <p class="textBody">
                    <asp:Image ID="PhotoImage" runat="server"
                               ImageUrl='<%# GetPhotoPath(Eval("ImagePath")) %>'
                               AlternateText="<%# Bind('Title') %>"
                               CssClass="centered" />
                </p>

                <p class="textBody"><asp:Label ID="DescriptionLabel" runat="server" Text='<%# Convert.ToString(Eval("Description")).Replace(Environment.NewLine, "<br />") %>' /></p>
   
                <p class="submitButton">
                    <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" 
                                onclick="DeleteButton_Click" Visible="<%# ModificationPermitted() %>"/>
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" 
                                onclick="EditButton_Click" Visible="<%# ModificationPermitted() %>"/>
                </p>
            </ItemTemplate>
        </asp:FormView>
</asp:Content>
